<?php
class BetChk
{

    public $today;

    public function BetChk( $today )
    {
        $this->today = $today;
    }

    public function chkBetDate( )
    {
        include_once( "class/MyLotto_3d.php" );
        global $conf;
        global $ui;
        $MyLotto_3d = new MyLotto_3d( 0 );
        $reVal = false;
        if ( $lotto_data = $MyLotto_3d->getLotto3DByDate( $this->today ) )
        {
            $datehi = date( "Hi" );
            if ( $conf->get( "stopbet_3d" ) <= $datehi )
            {
                $ui->showErrorPage( "目前非下单时段！", true );
                $reVal = false;
                exit();
            }
            else
            {
                if ( $datehi < $conf->get( "startbet_3d" ) )
                {
                    $ui->showErrorPage( "目前非下单时段！", true );
                    $reVal = false;
                    exit();
                }
                else
                {
                    $reVal = $lotto_data;
                }
            }
        }
        else
        {
            $ui->showErrorPage( "目前无可下注期数！", true );
            $reVal = false;
            exit();
        }
        return $reVal;
    }

    public function chkBetDateJSON( )
    {
        include_once( "class/MyLotto_3d.php" );
        global $conf;
        global $ui;
        $MyLotto_3d = new MyLotto_3d( 0 );
        $reVal = false;
        if ( $lotto_data = $MyLotto_3d->getLotto3DByDate( $this->today ) )
        {
            $datehi = date( "Hi" );
            if ( $conf->get( "stopbet_3d" ) <= $datehi )
            {
                header( "Cache-Control: no-cache, must-revalidate" );
                header( "Content-Type: text/plain" );
                echo "{\"msg\":\"2\"}";
                $reVal = false;
                exit();
            }
            else
            {
                if ( $datehi < $conf->get( "startbet_3d" ) )
                {
                    header( "Cache-Control: no-cache, must-revalidate" );
                    header( "Content-Type: text/plain" );
                    echo "{\"msg\":\"2\"}";
                    $reVal = false;
                    exit();
                }
                else
                {
                    $reVal = $lotto_data;
                }
            }
        }
        else
        {
            header( "Cache-Control: no-cache, must-revalidate" );
            header( "Content-Type: text/plain" );
            echo "{\"msg\":\"2\"}";
            $reVal = false;
            exit();
        }
        return $reVal;
    }

}

?>